package cn.sc.allinpay.allfavour.business.check;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

import java.util.List;

import cn.pai.mvp.callback.MpCallBack;
import cn.sc.allinpay.allfavour.base.connect.http.AppRequest;
import cn.sc.allinpay.allfavour.base.connect.http.RequestManager;
import cn.sc.allinpay.allfavour.base.model.BaseModel;
import cn.sc.allinpay.allfavour.business.common.data.CheckCouponData;

/**
 * 验券
 * author：pany
 * on 2017/12/5 14:44
 */
public class CheckModel extends BaseModel {

    /**
     * 通过券号查询卡券信息
     *
     * @param couponNo   券号
     * @param mpCallBack
     */
    public void reqQueryCouponByNo(String couponNo, final MpCallBack<List<CheckCouponData>, String> mpCallBack) {
        RequestManager.reqQueryCouponByNo(couponNo, new AppRequest.RequestCall() {
            @Override
            protected void onSuccess(JSONObject response) {
                List<CheckCouponData> datas = JSON.parseArray(response.getString("data"), CheckCouponData.class);
                mpCallBack.onSuccess(datas);
            }

            @Override
            public void onFailure(JSONObject response, String message) {
                mpCallBack.onFailure(response != null ? response.toString() : null, message);
            }
        });
    }
}
